<template>
    <StElDynamicForm ref="form" :submit-props="{method: 'post',url: GenUrl.genComponent,label: '生成',msg: '生成成功'}"
                      @requestSuccess="requestSuccess"
                     :options="formOptions" :origin-prop="{inline: false}" :layout="1">
    </StElDynamicForm>
</template>

<script>
    import GenUrl from './GenUrl.js'

    export default {
        name: "GenComponent",
        computed: {
            GenUrl(){
                return GenUrl
            }
        },
        data(){
            return {
                formOptions: [
                    {
                        field: {
                            name: 'componentName'
                        },
                        element: {
                            label: '名称',
                            required: true
                        }
                    }
                    ,{
                        field: {
                            name: 'position',
                            value: 'components'
                        },
                        element: {
                            label: '位置',
                            type: 'radioGroup',
                            options: {
                                datas: [
                                    {
                                        id: 'components',
                                        name: 'components',
                                    },
                                    {
                                        id: 'modules',
                                        name: 'modules',
                                    }
                                ]
                            }
                        }
                    },
                ]
            }
        },
        methods:{
            requestSuccess(data){
                let form = this.$refs.form.getFormData()
                this.$notify({
                    title: '标题名称',
                    message: '需要在父级中添加模块选项 <module>'+ form.componentName +'</module>'
                });
            }
        }
    }
</script>

<style scoped>

</style>